<?php
class Semester_Model_DbTable_SemesterDuration extends Zend_Db_Table
{
	protected $_name = 'semester_duration';
	protected $_primary = 'sn';

	/**
	 *
	 * 取得目前學年學期

	function get_curr_year_seme(){
		//以開始日設定回應
		$query = "SELECT * FROM semester_duration WHERE  started_date<=now() ORDER BY started_date DESC LIMIT 1";

		$res = $this->getAdapter()->query($query)->fetchAll();

		if (!empty($res)) {
			$res = $this->getAdapter()->query($query)->fetch();

		}
		else{
			$res['semester'] = (date("m")>7)?1:2;
			if ($res['semester']==1)
			$res['year'] = date("Y")-1911;
			else
			$res['year'] = date("Y")-1912;


		}
		$res ['year_seme'] = sprintf("%03d%d",$res['year'],$res['semester']);

		return $res;
	}


	function getAllYearSemester()
	{
		$arr = array();
		foreach($this->fetchAll(null,"year DESC") as $row){
			$year_semester = sprintf("%03d%d",$row->year,$row->semester);
			$arr[$year_semester] = $row->year."學年第".$row->semester."學期";
		}
		return $arr;
	}

*/
}